package com.amap.map.util.version;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.amap.map.network.entity.UploadData;
import com.amap.map.network.handler.DataUploadHandler;
import com.amap.map.util.Configuration;
import com.amap.map.util.network.HttpConnectionUtil;
import com.amap.map.util.network.RequestHead;
import com.amap.map.util.network.HttpConnectionUtil.HttpConnectionCallback;
import com.amap.map.util.network.HttpConnectionUtil.HttpMethod;

public class VersionQueryHandler {
	
	private Map<String, String> params = new HashMap<String, String>() ;
	VersionUpdate version ;
	
	public VersionQueryHandler( int versionCode,String versionName ,VersionUpdate version ){
		 params.put("reqHead", JSON.toJSONString( new RequestHead(102, new Date().toString() )));
		 params.put("bodyParam", versionCode + "");
		 this.version = version ;
	}

	public void run() {
		//自定义类,封装了GET/POST方法,而且同样也封装了同步跟异步的方法
		HttpConnectionUtil conn = new HttpConnectionUtil();
		conn.asyncConnect( Configuration.NETWORK_RUL , params, HttpMethod.POST,
			new HttpConnectionCallback(){
				@Override
				public void execute(String response)
				{
					version.notification(response) ;
				}
			}
		);
	}
	
}
